﻿using MvcBoard.Domain.Abstract;
using MvcBoard.Domain.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MvcBoard.Domain.Concrete
{
    public class EFMvcBoardRepository : IMvcBoardRepository
    {
        private EFDbContext context = new EFDbContext();

        public IQueryable<Board> Boards { get { return context.Boards; } }

        public void SaveBoard(Board board)
        {
            if (board.BoardID == 0)
            {
                context.Boards.Add(board);
            }
            else
            {
                context.SaveChanges();
            }
        }

        public void DeleteBoard(Board board)
        {
            context.Boards.Remove(board);
            context.SaveChanges();
        }
    }
}
